﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace WindowsGame2
{
    class Link
    {
        Rectangle area;
        float rotation;

        public Link(Vector2 pos1, Vector2 pos2)
        {
            int difx = (int)(pos2.X - pos1.X);
            int dify = (int)(pos2.Y - pos1.Y);
            int dist = (int)Math.Sqrt((difx * difx) + (dify * dify));

            area = new Rectangle((int)pos1.X, (int)pos1.Y, dist, 2);

            rotation = (float)Math.Atan2(dify, difx);
        }

        public void draw(SpriteBatch spriteBatch, Texture2D texture)
        {
            spriteBatch.Draw(texture, area, null, Color.Black, rotation, Vector2.Zero, SpriteEffects.None, 0);
        }
    }
}
